﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using BOHVote.Common;
using BOHVote.BLL;

namespace BOH.Information.Report
{
    public partial class ReportPersonalInfo : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.Title = common.getAppSetting("AppName");
                string SubjectName = string.Empty;
                string GovernName = string.Empty;
                string ApplyImg = string.Empty;
                string Period = string.Empty;
                if (Request.QueryString["ID"] != null && !string.IsNullOrEmpty(Request.QueryString["ID"].ToString()))
                {
                    string ApplyID = System.Text.Encoding.Default.GetString(Convert.FromBase64String(Request.QueryString["ID"].ToString().Replace("%2B", "+")));
                    //string ApplyID = Request.QueryString["ID"].ToString();
                    hiddenApplyID.Value = ApplyID;
                    //XSD.PersonalInfo xsd = BindReport(ApplyID, out SubjectName, out GovernName, out ApplyImg, out Period);

                    //ReportViewBind(xsd);//, SubjectName, GovernName, ApplyImg, "", Period);
                    FillForm(ApplyID);
                }
                //else if (Request.QueryString["ApplyStyle"] != null && Request.QueryString["ApplyType"] != null && Request.QueryString["Govern"] != null && Request.QueryString["Unit"] != null && Request.QueryString["Subject"] != null && Request.QueryString["Speciality"] != null && Request.QueryString["ApplyJobRank"] != null)
                //{
                //    string ApplyStyle = Request.QueryString["ApplyStyle"].ToString();
                //    string ApplyType = Request.QueryString["ApplyType"].ToString();
                //    string Govern = Request.QueryString["Govern"].ToString();
                //    string Unit = Request.QueryString["Unit"].ToString();
                //    string Subject = Request.QueryString["Subject"].ToString();
                //    string Speciality = Request.QueryString["Speciality"].ToString();
                //    string ApplyJobRank = Request.QueryString["ApplyJobRank"].ToString();
                //    DataSet dst = ApplyClass.dstApplys(Unit, Govern, ApplyStyle, ApplyType, Speciality, Subject, ApplyJobRank, (string)Session["ApplyPeriod"]);
                //    //XSD.PersonalInfo xsd = BindPersonalList(Unit, Govern, ApplyStyle, ApplyType, Speciality, Subject, ApplyJobRank, (string)Session["ApplyPeriod"]);
                //    //ReportViewBind(xsd);
                //}
            }
        }

        public void FillForm(string ID)
        {
            DataSet dstApply = ApplyClass.getApplyByID(ID);
            if (dstApply.Tables[0].Rows.Count > 0)
            {
                lblApplyName.Text = dstApply.Tables[0].Rows[0]["Apply_Name"].ToString();
                lblGender.Text = common.GenderTypeName(dstApply.Tables[0].Rows[0]["Gender"].ToString().Trim());
                if (!string.IsNullOrEmpty(dstApply.Tables[0].Rows[0]["Birthday"].ToString()))
                    lblBirthday.Text = Convert.ToDateTime(dstApply.Tables[0].Rows[0]["Birthday"].ToString().Trim()).ToString("yyyy-MM");
                else
                    lblBirthday.Text = "-";

                lblMobile.Text = dstApply.Tables[0].Rows[0]["ApplyMobile"].ToString();

                //if (!string.IsNullOrEmpty(dstApply.Tables[0].Rows[0]["ApplyImage"].ToString().Trim()))
                //{
                //    panelShowPhoto.Visible = true;
                //    imgPhoto.ImageUrl = common.getAppSetting("FolderforLoadPath") + "/" + dstApply.Tables[0].Rows[0]["ApplyPeriodID"].ToString().Trim() + "/" + dstApply.Tables[0].Rows[0]["ApplyImage"].ToString().Trim();//Server.MapPath("UploadFile") + "\\" + dstApply.Tables[0].Rows[0]["ApplyImage"].ToString().Trim();
                //}
                //else
                //    panelShowPhoto.Visible = false;
                //hiddenPPTFile.Value = dstApply.Tables[0].Rows[0]["ApplyPPT"].ToString().Trim();
                //if (!string.IsNullOrEmpty(hiddenPPTFile.Value))
                //{
                //    ShowPPT.Visible = true;
                //    ShowPPT.NavigateUrl = common.getAppSetting("FolderforLoadPath") + "/" + dstApply.Tables[0].Rows[0]["ApplyPeriodID"].ToString().Trim() + "/" + hiddenPPTFile.Value;
                //}

                lblIDCard.Text = dstApply.Tables[0].Rows[0]["IDCard"].ToString().Trim();

                if (!string.IsNullOrEmpty(dstApply.Tables[0].Rows[0]["UnitID"].ToString().Trim()))
                    lblUnit.Text = UnitClass.getUnitName(dstApply.Tables[0].Rows[0]["UnitID"].ToString().Trim());
                if (!string.IsNullOrEmpty(dstApply.Tables[0].Rows[0]["GovernID"].ToString().Trim()))
                {
                    //lblGovern.Text = UnitClass.GetGovernName(dstApply.Tables[0].Rows[0]["GovernID"].ToString().Trim());
                    labGovernTitle.Text = UnitClass.GetGovernName(dstApply.Tables[0].Rows[0]["GovernID"].ToString().Trim());
                }
                lblEducation.Text = DictManageClass.GetDicNameByValue("educationlevel", dstApply.Tables[0].Rows[0]["EducationLevel"].ToString().Trim());
                if (!string.IsNullOrEmpty(dstApply.Tables[0].Rows[0]["GraduationDate"].ToString()))
                    lblGraduationTime.Text = Convert.ToDateTime(dstApply.Tables[0].Rows[0]["GraduationDate"].ToString().Trim()).ToString("yyyy-MM");
                else
                    lblGraduationTime.Text = "-";

                lblGraduationSchool.Text = dstApply.Tables[0].Rows[0]["School"].ToString().Trim();
                lblCurrentJobRank.Text = OtherClass.getJobRankName(dstApply.Tables[0].Rows[0]["CurrentJobRankID"].ToString().Trim());

                if (!string.IsNullOrEmpty(dstApply.Tables[0].Rows[0]["JobDate"].ToString()))
                    lblGetJobRankTime.Text = Convert.ToDateTime(dstApply.Tables[0].Rows[0]["JobDate"].ToString().Trim()).ToString("yyyy-MM");
                else
                    lblGetJobRankTime.Text = "-";

                lblEmploymentLife.Text = dstApply.Tables[0].Rows[0]["JobTerm"].ToString().Trim();
                if (!string.IsNullOrEmpty(dstApply.Tables[0].Rows[0]["ConversionDate"].ToString()))
                    lblConversionDate.Text = Convert.ToDateTime(dstApply.Tables[0].Rows[0]["ConversionDate"].ToString().Trim()).ToString("yyyy-MM");
                else
                    lblConversionDate.Text = "-";
                string strApplyJobRank = dstApply.Tables[0].Rows[0]["JobRankID"].ToString().Trim();
                lblApplyJobRank.Text = OtherClass.getJobRankName(strApplyJobRank);
                //lblSubject.Text = Subject.getSubjectNameBySubjectID(dstApply.Tables[0].Rows[0]["SubjectID"].ToString().Trim());
                string strSubject = dstApply.Tables[0].Rows[0]["SubjectID"].ToString().Trim();
                labSubjectTitle.Text = Subject.getSubjectNameBySubjectID(strSubject);
                
                lblSpeciality.Text = Subject.getSpecialityName(dstApply.Tables[0].Rows[0]["SpecialityID"].ToString().Trim());
                lblApplyStatus.Text = DictManageClass.GetDicNameByValue("ApplyType", dstApply.Tables[0].Rows[0]["ApplyType"].ToString().Trim());
                //lblApplyPeriod.Text = dstApply.Tables[0].Rows[0]["ApplyPeriodID"].ToString().Trim() + "年度";
                labApplyPeriodTitle.Text = dstApply.Tables[0].Rows[0]["ApplyPeriodID"].ToString().Trim() + "年度";
                lblRegularJob.Text = DictManageClass.GetDicNameByValue("FixedJob",dstApply.Tables[0].Rows[0]["FixedJob"].ToString().Trim());
                lblLanguage.Text = OtherClass.getLanguageName(dstApply.Tables[0].Rows[0]["ForeignLanguageName"].ToString().Trim());
                lblLanguageLevel.Text = DictManageClass.GetDicNameByValue("ForeignLanguageResult", dstApply.Tables[0].Rows[0]["ForeignLanguageResult"].ToString().Trim());
                lblComputerLevel.Text = DictManageClass.GetDicNameByValue("ComputerResult", dstApply.Tables[0].Rows[0]["ComputerResult"].ToString().Trim());
                lbljobResult.Text = dstApply.Tables[0].Rows[0]["JobResult"].ToString().Trim();
                lblPoliticalResult.Text = dstApply.Tables[0].Rows[0]["PoliticsResult"].ToString().Trim();
                lblApplyplight.Text = common.Applyplight(dstApply.Tables[0].Rows[0]["Applyplight"].ToString().Trim());

                if (!string.IsNullOrEmpty(dstApply.Tables[0].Rows[0]["LastApplyDate"].ToString()))
                    lblLastApplyTime.Text = Convert.ToDateTime(dstApply.Tables[0].Rows[0]["LastApplyDate"].ToString().Trim()).ToString("yyyy-MM");
                else
                    lblLastApplyTime.Text = "-";

                lblSpecialityName.Text = dstApply.Tables[0].Rows[0]["SpecialityName"].ToString().Trim();

                if (!string.IsNullOrEmpty(dstApply.Tables[0].Rows[0]["SpecialitDateTime"].ToString()))
                    lblSpecialityEndTime.Text = Convert.ToDateTime(dstApply.Tables[0].Rows[0]["SpecialitDateTime"].ToString().Trim()).ToString("yyyy-MM");
                else
                    lblSpecialityEndTime.Text = "-";

                lblSpecialityLevel.Text = DictManageClass.GetDicNameByValue("SpecialityLevel", dstApply.Tables[0].Rows[0]["SpecialityLevel"].ToString().Trim());
                lblSpecialitapproveUnit.Text = dstApply.Tables[0].Rows[0]["SpecialitapproveUnit"].ToString().Trim();
                lblSpecialitPersonalRank.Text = DictManageClass.GetDicNameByValue("SpecialitPersonalRank", dstApply.Tables[0].Rows[0]["SpecialitPersonalRank"].ToString().Trim());
                lblAwardsName.Text = dstApply.Tables[0].Rows[0]["AwardsName"].ToString().Trim();
                lblAwardsDateTime.Text = dstApply.Tables[0].Rows[0]["AwardsDateTime"].ToString().Trim();
                lblAwardsLevel.Text = DictManageClass.GetDicNameByValue("AwardsLevel", dstApply.Tables[0].Rows[0]["AwardsLevel"].ToString().Trim());
                lblAwardsRank.Text = DictManageClass.GetDicNameByValue("AwardsRank", dstApply.Tables[0].Rows[0]["AwardsRank"].ToString().Trim());
                lblAwardsPersonalRank.Text = dstApply.Tables[0].Rows[0]["AwardsPersonalRank"].ToString().Trim();


                if (strApplyJobRank == "53" && strSubject == "KY-1")
                {
                    divSpecialityAwards.Visible = true;

                    lblSpecialityName1.Text = dstApply.Tables[0].Rows[0]["SpecialityName1"].ToString().Trim();

                    if (!string.IsNullOrEmpty(dstApply.Tables[0].Rows[0]["SpecialitDateTime1"].ToString()))
                        lblSpecialityEndTime1.Text = Convert.ToDateTime(dstApply.Tables[0].Rows[0]["SpecialitDateTime1"].ToString().Trim()).ToString("yyyy-MM");
                    else
                        lblSpecialityEndTime1.Text = "-";
                    lblSpecialityLevel1.Text = DictManageClass.GetDicNameByValue("SpecialityLevel", dstApply.Tables[0].Rows[0]["SpecialityLevel1"].ToString().Trim());
                    lblSpecialitapproveUnit1.Text = dstApply.Tables[0].Rows[0]["SpecialitapproveUnit1"].ToString().Trim();
                    lblSpecialitPersonalRank1.Text = DictManageClass.GetDicNameByValue("SpecialitPersonalRank", dstApply.Tables[0].Rows[0]["SpecialitPersonalRank1"].ToString().Trim());
                    lblAwardsName1.Text = dstApply.Tables[0].Rows[0]["AwardsName1"].ToString().Trim();
                    lblAwardsDateTime1.Text = dstApply.Tables[0].Rows[0]["AwardsDateTime1"].ToString().Trim();
                    lblAwardsLevel1.Text = DictManageClass.GetDicNameByValue("AwardsLevel", dstApply.Tables[0].Rows[0]["AwardsLevel1"].ToString().Trim());
                    lblAwardsRank1.Text = DictManageClass.GetDicNameByValue("AwardsRank", dstApply.Tables[0].Rows[0]["AwardsRank1"].ToString().Trim());
                    lblAwardsPersonalRank1.Text = dstApply.Tables[0].Rows[0]["AwardsPersonalRank1"].ToString().Trim();
                }

                if (!string.IsNullOrEmpty(dstApply.Tables[0].Rows[0]["ApplyID"].ToString().Trim()))
                {
                    #region << ApplyPublicity  >>
                    DataSet dstApplyPublicity = ApplyClass.dstApplyPublicity(dstApply.Tables[0].Rows[0]["ApplyID"].ToString().Trim());
                    if (dstApplyPublicity.Tables.Count > 0 && dstApplyPublicity.Tables[0].Rows.Count > 0)
                    {
                        lblStartShowMonth.Text = dstApplyPublicity.Tables[0].Rows[0]["startmonth"].ToString().Trim();
                        lblStartShowDay.Text = dstApplyPublicity.Tables[0].Rows[0]["startday"].ToString().Trim();
                        lblEndShowMonth.Text = dstApplyPublicity.Tables[0].Rows[0]["endmonth"].ToString().Trim();
                        lblEndShowDay.Text = dstApplyPublicity.Tables[0].Rows[0]["endday"].ToString().Trim();
                        lblShowAddress.Text = dstApplyPublicity.Tables[0].Rows[0]["address"].ToString().Trim();
                        if (dstApplyPublicity.Tables[0].Rows[0]["response"].ToString().Trim() == "0")
                            lblShowResponse.Text = "无";
                        else
                            lblShowResponse.Text = "有";
                    }
                    #endregion

                    #region <<  论文绑定 >>
                    DataSet dstThesis = ApplyClass.dstThesis(dstApply.Tables[0].Rows[0]["ApplyID"].ToString().Trim());
                    //int icount1 = 1;
                    //int icount2 = 1;
                    //int icount3 = 1;
                    //int icount4 = 1;
                    string FileFullPath = common.getAppSetting("FolderforLoadPath") + "/" + dstApply.Tables[0].Rows[0]["ApplyPeriodID"].ToString().Trim() + "/";
                    foreach (DataRow drThesis in dstThesis.Tables[0].Rows)
                    {
                        switch (drThesis["SeqID"].ToString())
                        {
                            case "1":
                                {
                                    lblPaperTitle1.Text = drThesis["ThesisTitle"].ToString();
                                    lblJournalsNo1.Text = drThesis["JournalsNo"].ToString();
                                    lblPeriodicalNo1.Text = drThesis["PeriodicalNo"].ToString();
                                    //if (!string.IsNullOrEmpty(drThesis["PagersPrint"].ToString()))
                                    //{
                                    //    string[] arrPagerImgs = drThesis["PagersPrint"].ToString().Split(new char[] { ';' });
                                    //    foreach (string pagerImgs in arrPagerImgs)
                                    //    {
                                    //        if (pagerImgs.Trim().Length > 0)
                                    //        {
                                    //            if (icount1 == 1)
                                    //                this.showLink1.HRef = FileFullPath + pagerImgs;
                                    //            else
                                    //            {
                                    //                this.spanImgList1.InnerHtml += "<a href='" + FileFullPath + pagerImgs + "' class='zoom' rel='group'></a>";
                                    //            }
                                    //            ShowPaper1.Visible = true;
                                    //            icount1++;
                                    //        }
                                    //    }
                                    //}
                                    break;
                                }
                            case "2":
                                {
                                    lblPaperTitle2.Text = drThesis["ThesisTitle"].ToString();
                                    lblJournalsNo2.Text = drThesis["JournalsNo"].ToString();
                                    lblPeriodicalNo2.Text = drThesis["PeriodicalNo"].ToString();
                                    //if (!string.IsNullOrEmpty(drThesis["PagersPrint"].ToString()))
                                    //{
                                    //    string[] arrPagerImgs = drThesis["PagersPrint"].ToString().Split(new char[] { ';' });
                                    //    foreach (string pagerImgs in arrPagerImgs)
                                    //    {
                                    //        if (pagerImgs.Trim().Length > 0)
                                    //        {
                                    //            if (icount2 == 1)
                                    //                this.showLink2.HRef = FileFullPath + pagerImgs;
                                    //            else
                                    //            {
                                    //                this.spanImgList2.InnerHtml += "<a href='" + FileFullPath + pagerImgs + "' class='zoom' rel='group'></a>";
                                    //            }
                                    //            ShowPaper2.Visible = true;
                                    //            icount2++;
                                    //        }
                                    //    }
                                    //}
                                    break;
                                }
                            case "3":
                                {
                                    lblPaperTitle3.Text = drThesis["ThesisTitle"].ToString();
                                    lblJournalsNo3.Text = drThesis["JournalsNo"].ToString();
                                    lblPeriodicalNo3.Text = drThesis["PeriodicalNo"].ToString();
                                    //if (!string.IsNullOrEmpty(drThesis["PagersPrint"].ToString()))
                                    //{
                                    //    string[] arrPagerImgs = drThesis["PagersPrint"].ToString().Split(new char[] { ';' });
                                    //    foreach (string pagerImgs in arrPagerImgs)
                                    //    {
                                    //        if (pagerImgs.Trim().Length > 0)
                                    //        {
                                    //            if (icount3 == 1)
                                    //                this.showLink3.HRef = FileFullPath + pagerImgs;
                                    //            else
                                    //            {
                                    //                this.spanImgList3.InnerHtml += "<a href='" + FileFullPath + pagerImgs + "' class='zoom' rel='group'></a>";
                                    //            }
                                    //            ShowPaper3.Visible = true;
                                    //            icount3++;
                                    //        }
                                    //    }
                                    //}
                                    break;
                                }
                            case "4":
                                {
                                    //lblPaperTitle4.Text = drThesis["ThesisTitle"].ToString();
                                    //lblJournalsNo4.Text = drThesis["JournalsNo"].ToString();
                                    //lblPeriodicalNo4.Text = drThesis["PeriodicalNo"].ToString();
                                    //if (!string.IsNullOrEmpty(drThesis["PagersPrint"].ToString()))
                                    //{
                                    //    string[] arrPagerImgs = drThesis["PagersPrint"].ToString().Split(new char[] { ';' });
                                    //    foreach (string pagerImgs in arrPagerImgs)
                                    //    {
                                    //        if (pagerImgs.Trim().Length > 0)
                                    //        {
                                    //            if (icount4 == 1)
                                    //                this.showLink4.HRef = FileFullPath + pagerImgs;
                                    //            else
                                    //            {
                                    //                this.spanImgList4.InnerHtml += "<a href='" + FileFullPath + pagerImgs + "' class='zoom' rel='group'></a>";
                                    //            }
                                    //            ShowPaper4.Visible = true;
                                    //            icount4++;
                                    //        }
                                    //    }
                                    //}
                                    break;
                                }
                            default:
                                break;
                        }
                    }
                    #endregion
                }
            }
        }
    }
}
